package pages.entrys;

import tools.Tools;
import utils.BackgroundPanel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Entry extends JFrame {

    private final SheZhi shezhi = new SheZhi();

    public Entry(){

        //frame
        this.setSize(1200,660);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //contentPane
        BackgroundPanel contentPane = new BackgroundPanel();
        this.setContentPane(contentPane);
        contentPane.setImage(Tools.beijing);
        contentPane.setSize(1200,660);
        //mouseListener
        this.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int x = e.getX();
                int y = e.getY();
                System.out.println(x+";"+y);
            }
        });

        //buttons
        JButton button_1 = new JButton("开始游戏");
        JButton button_2 = new JButton("设置");
        contentPane.add(button_1);
        contentPane.add(button_2);
        button_1.setBounds(400,370,320,80);
        button_2.setBounds(400,460,320,80);
        button_1.setBackground(Color.ORANGE);
        button_2.setBackground(Color.ORANGE);
        button_1.setFont(new Font(null,Font.BOLD,20));
        button_2.setFont(new Font(null,Font.BOLD,20));
        //actionListener
        button_1.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {

                new Entry2();
            }
        });
        button_2.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {

                shezhi.setVisible(true);
            }
        });


    }

    public static void main(String[] args) {
        new Entry();
    }
}
